package com.qch.edu.lagou.algorithm.greedy;

/**
 * @Author qch
 * @Date 2021/7/22
 * 物品
 */
public class Goods implements Comparable{
    String name;
    double weight;
    double price;
    double value;//价值

    public Goods(String name, double weight, double price) {
        this.name = name;
        this.weight = weight;
        this.price = price;
        this.value=price/weight;
    }

    public int compareTo(Object o) {
        Goods goods=(Goods)o;
        if(this.value==goods.value){
            return 0;			//如果学号相同，那么两者就是相等的
        }else if(this.value>goods.value){
            return -1;			//如果这个学生的学号大于传入学生的学号
        }else{
            return 1;			//如果这个学生的学号小于传入学生的学号
        }
    }
}
